package io.renren.modules.lucky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.lucky.dao.LuckyUserConfigDao;
import io.renren.modules.lucky.dto.LuckyUserConfigDTO;
import io.renren.modules.lucky.entity.LuckyUserConfigEntity;
import io.renren.modules.lucky.service.LuckyUserConfigService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 招财猫租户配置
 *
 * @author Liang Pei 
 * @since 1.0.0 2025-01-07
 */
@Service
public class LuckyUserConfigServiceImpl extends CrudServiceImpl<LuckyUserConfigDao, LuckyUserConfigEntity, LuckyUserConfigDTO> implements LuckyUserConfigService {

    @Override
    public QueryWrapper<LuckyUserConfigEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<LuckyUserConfigEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public LuckyUserConfigEntity getEntityByUnionKey(String unionKey) {
        return baseDao.selectOne(new QueryWrapper<LuckyUserConfigEntity>().eq("union_key", unionKey));
    }

    @Override
    public LuckyUserConfigEntity getEntityByUid(Long uid) {
        return baseDao.selectOne(new QueryWrapper<LuckyUserConfigEntity>().eq("uid", uid));
    }

    @Override
    public List<LuckyUserConfigEntity> getAll() {
        return baseDao.selectList(null);
    }
}